<template>
  <a-modal title="历史版本信息" :visible="visible" @cancel="cancel" :footer="null"  width="900px">
    <a-table :columns="columns" :data-source="dataList"  :pagination="false">
    <span slot="versionNumber" slot-scope="text,record">
           V{{text}}
        </span>
      <span slot="action" slot-scope="text, record">
        <a-button type="primary" @click="detailed(record)" size="small"> 查看详情 </a-button>
      </span>
    </a-table>
  </a-modal>
</template>
<script>
import {getProgramHistoryList} from '@/api/technical/approval'
const columns = [
  { title: '版本号', dataIndex: 'versionNumber',scopedSlots: { customRender: 'versionNumber' }},
  { title: '上传时间', dataIndex: 'fiDate' },
  { title: '操作', scopedSlots: { customRender: 'action' } }
]

export default {
  props: {
    // 显隐控件
    visible: {
      type: Boolean,
      default() {
        return false
      }
    },
    versionId:{
      type:String,
      default(){
        return ''
    }
  }
  },
  data() {
    return {
      dataList: [],
      columns
    }
  },
  watch: {
    visible: {
      immediate: true,
      handler(val) {
        if (val) {
          this.getProgramHistoryListFn();
        }
      }
    },
  },
  methods: {
    cancel() {
        this.$emit('cancel',false)
    },
    getProgramHistoryListFn(){
      getProgramHistoryList({id:this.versionId}).then((res)=>{
        this.dataList = res.data;
      })
    },
    //查看历史数据详情
    detailed(record) {
      this.$router.push({
        path: '/technical/ShiGroup/Approval/EditFrom',
        query: {
          type: 'view',
          id: record.id,
          historicalData:true,
        }
      })
      this.$emit('cancel',false)
    },
  }
}
</script>